home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 February
/
Macworld (1999-02).dmg
/
Serious Demos
/
Portfolio 4.0.1
/
Scripting Extras
/
Change Path.txt
< prev
next >
Wrap
Text File
|
1998-09-15
|
2KB
|
49 lines
-- 1.01 - Check to make sure Portfolio is running
tell application "Finder"
set P_app to every process whose name contains "Portfolio"
if P_app is {} then
display dialog ¬
"Portfolio must be running for this script to operate." buttons {"OK"} default button {"OK"}
return
end if
end tell
--Get the appropriate search information from the user
set sSearch to text returned of (display dialog "Enter the value to search for:" default answer "")
set sReplace to text returned of (display dialog "Enter the new value to be substituted:" default answer sSearch)
set cButton to button returned of (display dialog "Choose the scope of the search: " buttons {"Entire Catalog", "Current Gallery"} default button 1)
set iSearchLen to the length of sSearch
tell application "Portfolio"
-- Find all the records beginning with sSearch
set theQuery to "Path" & tab & "starts with" & tab & sSearch
if cButton = "Entire Catalog" then
find record of front gallery matching theQuery in all records
else
find record of front gallery matching theQuery in shown records
end if
-- If no items were found, tell the user and then quit.
if result is 0 then
display dialog ¬
"No records match your search criteria." buttons {"OK"} default button {"OK"}
return
end if
-- Get the list of IDs of the found set.
set lRID to the id of every record in the front gallery as list
repeat with rID in lRID
-- Get the original path.
set fPath to field "path" of record id rID of front gallery
set iLeft to the length of fPath
set fLeftPath to the characters (iSearchLen + 1) through iLeft of fPath as string
set fNewPath to sReplace & fLeftPath as string
--Update the Portfolio location for that item
set path of record id rID of front gallery to fNewPath
end repeat
end tell